<!DOCTYPE html>
<html class="x-admin-sm">

<head>
    <meta charset="UTF-8">
    <title>考核申请</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
        content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
    <link rel="stylesheet" href="../css/font.css">
    <link rel="stylesheet" href="../css/iconfont.css">
    <link rel="stylesheet" href="../lib/layui/css/layui.css" media="all">

    <link rel="stylesheet" href="../css/xadmin.css">
    <script src="../lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="../js/xadmin.js"></script>
    <script src="../js/base.js"></script>
    <!-- 让IE8/9支持媒体查询，从而兼容栅格 -->
    <!--[if lt IE 9]>
    <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
    <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
    <style>
        tr td,
        tr th {
            text-align: center !important;
            border: none !important;
        }

        .layui-laydate-content tr td {
            border-bottom: none !important;
            border-top: none !important;
        }

        tr td {
            border-bottom: 1px solid #eee !important;
            border-top: 1px solid #eee !important;
        }

        .shaixuan .layui-col-md12 .layui-inline {
            margin: 0;
        }

        .shaixuan .layui-col-md12 .layui-inline.layui-col-md4 .layui-form-label {
            width: 30%;
            padding-left: 0;
        }

        .shaixuan .layui-col-md12 .layui-inline.layui-col-md4 .layui-input-inline {
            width: 53%;
        }

        .shaixuan .layui-col-md12 .layui-inline.layui-col-md4 {
            margin-bottom: 20px;
        }

        .shaixuan .layui-col-md12 .layui-inline.layui-col-md3 .layui-form-label {
            width: 30%;
            padding-left: 0;
        }

        .shaixuan .layui-col-md12 .layui-inline.layui-col-md3 .layui-input-inline {
            width: 90%;
        }

        .shaixuan .layui-col-md12 .layui-inline.layui-col-md3 {
            margin-bottom: 20px;
        }

        .shaixuan .layui-col-md12 .layui-inline.layui-col-md6 .layui-form-label {
            width: 30%;
            padding-left: 0;
        }

        .shaixuan .layui-col-md12 .layui-inline.layui-col-md6 .layui-input-inline {
            width: 53%;
        }

        .shaixuan .layui-col-md12 .layui-inline.layui-col-md6 {
            margin-bottom: 20px;
        }
    </style>
</head>

<body>
    <div class="layui-fluid">
        <div class="layui-row layui-col-space15">
            <div class="layui-col-md12">
                <div class="layui-card" style="display: flex;justify-content: space-between;">
                    <div class="layui-card-body ">
                        <blockquote class="layui-elem-quote" style="border:0;font-size: 18px;color: #000;">修改个人信息
                        </blockquote>
                    </div>
                </div>
            </div>

            <div class="layui-col-md12 shaixuan">
                <div class="layui-card">
                    <div class="layui-fluid">
                        <div style="text-align: center;font-size: 16px;margin-bottom: 10px;">基本信息</div>
                        <div class="layui-row layui-col-space15">
                            <div class="layui-col-md10">
                                <div class="layui-card-body " style="display: flex;justify-content:space-between">
                                    <form class="layui-form" action="" style="width: 100%;">
                                        <div class="layui-form-item layui-col-md12">
                                            <div class="layui-inline layui-col-md4">
                                                <label class="layui-form-label"><span
                                                        class="x-red">*</span>用户昵称：</label>
                                                <div class="layui-input-inline">
                                                    <input type="text" name="nickName" id="nickName"
                                                        lay-verify="required" autocomplete="off" class="layui-input">
                                                </div>
                                            </div>
                                            <div class="layui-inline layui-col-md4">
                                                <label class="layui-form-label"><span
                                                        class="x-red">*</span>真实姓名：</label>
                                                <div class="layui-input-inline">
                                                    <input type="text" name="name" id="name" lay-verify="required"
                                                        autocomplete="off" class="layui-input">
                                                </div>
                                            </div>
                                            <div class="layui-inline layui-col-md4">
                                                <label class="layui-form-label"><span class="x-red">*</span>性别：</label>
                                                <div class="layui-input-inline">
                                                    <select id="sex" name="sex" lay-verify="required">
                                                        <option value="1">男</option>
                                                        <option value="2">女</option>
                                                    </select>
                                                </div>
                                            </div>
                                            <div class="layui-inline layui-col-md4">
                                                <label class="layui-form-label"><span
                                                        class="x-red">*</span>出生日期：</label>
                                                <div class="layui-input-inline">
                                                    <input type="text" name="birthDay" id="birthDay" lay-verify="date"
                                                        autocomplete="off" class="layui-input">
                                                </div>
                                            </div>
                                            <div class="layui-inline layui-col-md4 identity" style="display: none;">
                                                <label class="layui-form-label"><span class="x-red">*</span>身份：</label>
                                                <div class="layui-input-inline">
                                                    <div id="identity"></div>
                                                </div>
                                            </div>
                                            <div class="layui-inline layui-col-md4 teamName" style="display: none;">
                                                <label class="layui-form-label"><span class="x-red">*</span>球队：</label>
                                                <div class="layui-input-inline">
                                                    <select id="teamName" name="teamName" lay-verify="required">
                                                        <option value="">请选择</option>
                                                    </select>
                                                </div>
                                            </div>
                                            <div class="layui-inline layui-col-md4">
                                                <label class="layui-form-label"><span
                                                        class="x-red">*</span>证件类型：</label>
                                                <div class="layui-input-inline">
                                                    <select id="documentType" name="documentType" lay-verify="required">
                                                        <option value="">请选择</option>
                                                        <option value="1">身份证</option>
                                                        <option value="2">护照</option>
                                                        <option value="3">户口本</option>
                                                    </select>
                                                </div>
                                            </div>
                                            <div class="layui-inline layui-col-md4">
                                                <label class="layui-form-label"><span
                                                        class="x-red">*</span>证件号码：</label>
                                                <div class="layui-input-inline">
                                                    <input type="text" name="documentNumber" id="documentNumber"
                                                        lay-verify="required" autocomplete="off" class="layui-input">
                                                </div>
                                            </div>
                                            <div class="layui-inline layui-col-md4">
                                                <label class="layui-form-label"><span
                                                        class="x-red">*</span>通信地址：</label>
                                                <div class="layui-input-inline">
                                                    <input type="text" name="address" id="address" lay-verify="required"
                                                        autocomplete="off" class="layui-input">
                                                </div>
                                            </div>
                                            <div class="layui-inline layui-col-md4">
                                                <label class="layui-form-label"><span class="x-red">*</span>城市：</label>
                                                <div class="layui-input-inline">
                                                    <select id="s_province" name="s_province" lay-verify="required"
                                                        lay-filter="s_province"></select>
                                                </div>
                                            </div>
                                            <div class="layui-inline layui-col-md4">
                                                <label class="layui-form-label"><span class="x-red">*</span>地区：</label>
                                                <div class="layui-input-inline">
                                                    <select id="s_city" name="s_city" lay-verify="required"
                                                        lay-filter="s_city"></select>
                                                </div>
                                            </div>
                                            <div class="layui-inline layui-col-md4">
                                                <label class="layui-form-label"><span
                                                        class="x-red">*</span>个人简介：</label>
                                                <div class="layui-input-inline">
                                                    <input type="text" name="introduction" id="introduction"
                                                        lay-verify="required" autocomplete="off" class="layui-input">
                                                </div>
                                            </div>
                                        </div>
                                    </form>
                                </div>
                            </div>
                            <div class="layui-col-md2">
                                <div style="border: 1px solid #ccc;width: 115px;height: 137px;">
                                    <img id="updateHeadImg" src="" alt=""
                                        style="width:100%;height:100%;position:relative;top:50%;left:50%;margin-top:-69px;margin-left:-58px">
                                </div>
                                <button type="button" class="layui-btn" id="uploadHeadImg"
                                    style="width: 114px;height: 33px;border-radius:5px;margin-top: 15px;margin-left: 2px;">
                                    上传图片
                                </button>
                                <div style="width: 114px;margin-top: 10px;">只能上传gif/jpg/png/bmp文件，且不超过5M</div>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="layui-form-item" style="text-align: center">
                    <button type="button" class="layui-btn submit">保存</button>
                </div>

                <!-- 表格部分开始 -->
                <table id="video_table" lay-filter="test" lay-data="{id: 'testReload'}"></table>
                <script type="text/html" id="barDemo2"></script>
                <script type="text/html" id="barDemo">
                    {{#  if(d.isPass == "0"){ }}
                    <a lay-event="drawback" class="btn_a layui-btn layui-btn-primary layui-btn-xs">审核</a>
                    {{#  } else { }}
                    <a lay-event="noClick"
                        class="btn_a layui-btn layui-btn-primary layui-btn-xs layui-btn-disabled">审核</a>
                    {{#  }}}
                    <a lay-event="drawbackLook" class="btn_a layui-btn layui-btn-xs">查看</a>
                </script>
                <!-- 表格结束 -->
            </div>
        </div>
    </div>
</body>

</html>
<script src="../js/area2.js"></script>
<script src="../lib/xm-select.js"></script>
<script>
    _init_area();
    var nickName, name, sex, birthDay, identity, teamName, documentType, documentType, documentType, documentNumber,
        address, city, area, introduction, headPhoto, teamId, perOrGroup, ID, IdentitId, identity1
    layui.use(['table', 'laydate', 'upload'], function () {
        var table = layui.table;
        var laydate = layui.laydate;
        var upload = layui.upload;
        var form = layui.form;

        $.ajax({
            url: findUserById,
            type: 'POST',
            success: function (data) {

                if (data.msg == '0') {
                    if (data.user.personalOrGroup == "1") {
                        identity1 = xmSelect.render({
                            el: '#identity',
                            language: 'zn',
                            name: 'identity',
                            on: function (data) {
                                //arr:  当前多选已选中的数据
                                var arr = data.arr;
                                var flag = false
                                for (var i = 0; i < arr.length; i++) {
                                    if (arr[i].value == "3") {
                                        flag = true
                                        break;
                                    }

                                }
                                if (flag) {
                                    $(".teamName").css("display", "block")
                                } else {
                                    $(".teamName").css("display", "none")
                                }
                            },
                            data: [{
                                    name: '教练员',
                                    value: 1
                                },
                                {
                                    name: '裁判员',
                                    value: 2
                                },
                                {
                                    name: '球员',
                                    value: 3
                                }
                            ]
                        })
                        identity1.setValue(data.user.IdentitId.split(","))
                    }
                    $.ajax({
                        url: playerGetTeamList,
                        type: 'POST',
                        success: function (res) {
                            if (res.msg == '0') {
                                for (var i = 0; i < res.teamList.length; i++) {
                                    $("#teamName").append("<option value='" + res
                                        .teamList[i].id + "'>" +
                                        res.teamList[i].name + "</option>")
                                }
                            }
                            form.render("select");
                            if (data.user.IdentitId.indexOf("3") !== -1) {
                                $(".teamName").css("display", "block")
                                $("#teamName").val(data.user.teamId)
                                form.render("select");
                            }
                        }
                    })

                }
            }
        })
        //第一个实例
        table.render({
            elem: '#video_table', //指定原始表格元素选择器（推荐id选择器）
            // height: 600,
            width: "100%",
            // where: { 'id': 1 },
            loading: true,
            method: 'get',
            url: LL_findApproval, //数据接口
            page: true, //开启分页
            // totalRow: true,
            parseData: function (res) { //res 即为原始返回的数据
                return {
                    "code": res.msg, //解析接口状态
                    "count": res.total, //解析数据长度
                    "data": res.data //解析数据列表
                    //     "code": 0, //解析接口状态
                    // 	"count": 9, //解析数据长度
                    // 	"data":  [
                    //         {
                    //             "createTime": "2020-02-05 11:16:40",
                    //             "teamId": 15,
                    //             "userId": 163,
                    //             "content": "kong1234同意了你的个人信息修改。",
                    //             "approveId": 53
                    //         },
                    //         {
                    //             "createTime": "2020-02-05 11:19:43",
                    //             "teamId": null,
                    //             "userId": 163,
                    //             "content": "kongyisong提交了个人信息修改",
                    //             "approveId": 54
                    //         }
                    //     ]//解析数据列表
                };
            },
            // toolbar: 'default', //开启工具栏，此处显示默认图标
            cols: [
                [ //表头
                    {
                        field: 'createTime',
                        title: '审核时间',
                        width: 200,
                        align: 'center',
                    },
                    {
                        field: 'content',
                        title: '审核内容',
                        width: 700,
                        align: 'center',
                    },
                ]
            ],
            id: 'testReload',
            done: function (res) {
                if (res.msg == "2") {
                    parent.window.location.href = getRequestPrefix() + "/footBallAdmin/login.html"
                }
            }
        });



        laydate.render({ //初始化时间选择
            elem: '#birthDay'
        });
        form.on('select(s_province)', function (data) {
            change(1);
            form.render('select');
        });
        form.on('select(s_city)', function (data) {
            change(2);
            form.render('select');
        });


        //上传头像
        var uploadInst = upload.render({
            elem: '#uploadHeadImg',
            url: uploadImg,
            exts: 'gif|jpg|png|bmp', //只允许上传后缀
            size: 5120,
            before: function (obj) {

            },
            done: function (res) {
                $('#updateHeadImg').attr('src', res.url);
                //如果上传成功
                if (res.msg == '0') {
                    layer.msg("上传成功")
                }
                //上传成功
            },
            error: function () {
                //演示失败状态，并实现重传
                var demoText = $('#demoText');
                demoText.html(
                    '<span style="color: #FF5722;">上传失败</span> <a class="layui-btn layui-btn-xs demo-reload">重试</a>'
                );
                demoText.find('.demo-reload').on('click', function () {
                    uploadInst.upload();
                });
            }
        });
        $(".submit").on("click", function () {
            nickName = $("#nickName").val()
            name = $("#name").val()
            sex = $("#sex").val()
            birthDay = $("#birthDay").val()
            if (perOrGroup !== "false") {
                identity = identity1.getValue('value').toString()
            }
            teamName = $("#teamName").val()
            documentType = $("#documentType").val()
            documentNumber = $("#documentNumber").val(),
                address = $("#address").val()
            city = $("#s_province").val()
            area = $("#s_city").val()
            introduction = $("#introduction").val()
            headPhoto = $("#updateHeadImg").attr("src")

            if (nickName == "" || nickName == undefined) {
                layer.msg("请输入用户昵称")
                return false
            }
            if (name == "" || name == undefined) {
                layer.msg("请输入真实姓名")
                return false
            }
            if (sex == "" || sex == undefined) {
                layer.msg("请选择性别")
                return false
            }
            if (birthDay == "" || birthDay == undefined) {
                layer.msg("请输入出生日期")
                return false
            }
            if (perOrGroup !== "false") {
                if (identity.length == "0" || identity == undefined) {
                    layer.msg("请选择身份")
                    return false
                }
            } else {
                identity = ""
            }
            if (identity.indexOf("3") !== -1) {
                if (teamName == "" || teamName == undefined) {
                    layer.msg("请选择球队")
                    return false
                }
            } else {
                teamName = ""
            }
            if (documentType == "" || documentType == undefined) {
                layer.msg("请选择证件类型")
                return false
            }
            if (documentNumber == "" || documentNumber == undefined) {
                layer.msg("请输入证件号码")
                return false
            }
            if (address == "" || address == undefined) {
                layer.msg("请输入通信地址")
                return false
            }
            if (city == "" || city == undefined) {
                layer.msg("请选择城市")
                return false
            }
            if (area == "" || area == undefined) {
                layer.msg("请选择地区")
                return false
            }
            if (introduction == "" || introduction == undefined) {
                layer.msg("请输入个人简介")
                return false
            }
            if (headPhoto == "" || headPhoto == undefined) {
                layer.msg("请上传头像")
                return false
            }
            // console.log(identity)
            // var urlUpdate = LL_alterCoach  //默认是教练员接口；
            // if(identity == 1){  //教练员
            //     urlUpdate = LL_alterCoach
            // }else if(identity == 2){  //裁判员
            //     urlUpdate = LL_alterCoach
            // }else if(identity == 3){ //球员
            //     urlUpdate = LL_alterCoach
            // }else if(identity == 4){  //其他
            //     urlUpdate = LL_alterCoach
            // }
            $.ajax({
                url: LL_alterCoach,
                type: 'get',
                data: {
                    nickName: nickName,
                    name: name,
                    birthDay: birthDay,
                    documentType: documentType,
                    documentNumber: documentNumber,
                    identity: identity,
                    city: city,
                    area: area,
                    sex: sex,
                    introduction: introduction,
                    id: ID ? ID : '163',
                    headPortraitUrl: headPhoto,
                    teamId: teamName,
                    // teamId: 1,
                    address: address
                },
                dataType: 'json',
                success: function (data) {
                    if (data.msg == 0) {
                        var index1 = parent.layer.getFrameIndex(window
                            .name); //先得到当前iframe层的索引
                        layer.alert("保存成功", {
                            title: '提示',
                            cancel: function (index, layero) {

                                parent.parent.window.location.reload()

                            }
                        }, function () {
                            parent.parent.window.location.reload()
                        })

                    } else {
                        layer.alert(data.msg, {
                            title: '提示'
                        })
                    }
                },
                error: function (data) {
                    console.log(data)
                    layer.alert(data.msg, {
                        title: '提示'
                    })
                }
            });

        })
    });
</script>